package com.yz.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yz.entity.Membership;
import com.yz.entity.dto.MembershipDto;
import com.yz.service.MembershipService;
import com.yz.util.Result;

@RestController
public class MembershipController {
	@Autowired
	private MembershipService membershipService;
	
	@RequestMapping("/getMemList")
	public Object getMemList(MembershipDto membershipDto,Membership membership) {
		List<Membership> list = membershipService.getMem(membershipDto);
		membershipDto.setPage(null);
		membershipDto.setLimit(null);
		List<Membership> list2 = membershipService.getMem(membershipDto);
		return new Result(0,"",list2.size(),list);
	}
	
	@RequestMapping("/addMem")
	public Object addMem(Membership membership) {
		if(membershipService.addMem(membership)) {
			return new Result(0,"添加成功");
		}else {
			return new Result(1,"添加失败");
		}
	}
	
	@RequestMapping("/updateMem")
	public Object updateMem(Membership membership) {
		if(membershipService.updateMem(membership)) {
			return new Result(0,"修改成功");
		}else {
			return new Result(1,"修改失败");
		}
	}
	
	@RequestMapping("/delMem")
	public Object delMem(int memid) {
		if(membershipService.delMem(memid)) {
			return new Result(0,"删除成功");
		}else {
			return new Result(1,"删除失败");
		}
	}
}
